Skip to content

Conversation

@Mirrowel
Copy link
Owner

@Mirrowel Mirrowel commented Jan 17, 2026

Updates the usage tracking logic to handle providers where local counting is more accurate than API returns (specifically Antigravity).


Important

Enhance quota tracking and retry handling for Antigravity by implementing local counting, retry tracking, and dynamic request limit learning.

  • Behavior:
    • Implement sync_mode in UsageManager to control API baseline effects on local counters (force, if_exhausted, none).
    • Configure Antigravity to use local counting as authoritative, disabling background refreshes.
    • Add on_retry_attempt callback in RotatingClient and AntigravityProvider to track retries (bare 429s, empty responses).
    • Introduce measured_max_requests tracking to learn actual request limits.
  • Functions:
    • increment_request_count() in UsageManager to track retries not covered by record_success/record_failure.
    • update_quota_baseline() in UsageManager updated to handle sync_mode and track measured_max_requests.
  • Misc:
    • Modify run_background_job() in gemini_credential_manager.py to disable Antigravity refreshes.

This description was created by Ellipsis for 3137f3b. You can customize this summary. It will automatically update as commits are pushed.

Updates the usage tracking logic to handle providers where local counting is more accurate than API returns (specifically Antigravity).

- Implement `sync_mode` in `UsageManager` (`force`, `if_exhausted`, `none`) to control how API baselines affect local counters.
- Configure Antigravity credential manager to treat local counting as authoritative, skipping background refreshes to prevent valid usage data from being overwritten by stale API data.
- Add `on_retry_attempt` callback in `RotatingClient` and `AntigravityProvider` to track internal retries (bare 429s, empty responses) that consume quota.
- Introduce `measured_max_requests` tracking to dynamically learn the actual request limit of credentials.
@Mirrowel
Copy link
Owner Author

@b3nw This is my take. Though, this feels way too bloated to commit without a major rethink. What do you think?

Difference here is that antigravity now only counts locally, except for first fetch and force fetch from the API. But, the retries in the provider make incrementing counts.. difficult.

@b3nw
Copy link
Contributor

b3nw commented Jan 17, 2026

@Mirrowel -- I think I'd probably merge #81 and observe to see if the invisible retries actually cause quota drift, right now its hard for me to tell, but at least with the first fix, we'd isolate the issue, and if confirmed, implement the more complex tracking.

@Mirrowel
Copy link
Owner Author

Mirrowel commented Jan 17, 2026

@Mirrowel -- I think I'd probably merge #81 and observe to see if the invisible retries actually cause quota drift, right now its hard for me to tell, but at least with the first fix, we'd isolate the issue, and if confirmed, implement the more complex tracking.

Oh i know it is the case. No need to confirm for me - this is because of reporting in 20% increments. So api fetches are essentially useless for measuring quota accurately.

It is also rounded a bit, as you can get quota exhausted before you get the error. Suggesting the api refresh happened and you got hit with 0 remaining.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants